import 'package:flutter/material.dart';

/// Sliver块
class StickyDelegate extends SliverPersistentHeaderDelegate {
  StickyDelegate({
    required this.child,
    this.maxHeight,
    this.sRebuild = true,
  });

  final Widget child;

  final double? maxHeight;

  final bool? sRebuild;

  @override
  Widget build(BuildContext context, double shrinkOffset, bool overlapsContent) => child;

  @override
  double get maxExtent => maxHeight ?? kToolbarHeight;

  @override
  double get minExtent => maxHeight ?? kToolbarHeight;

  @override
  bool shouldRebuild(SliverPersistentHeaderDelegate oldDelegate) {
    return sRebuild ?? (oldDelegate.maxExtent != maxHeight);
  }
}
